package com.ys.dubbo.cloud.rest.provider.service;

import com.ys.dubb.cloud.api.CalculateService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

/**
 * <p>@description: </p>
 *
 * @author yangshuang
 * @version 1.0
 * @date 2019/6/9 15:58
 */
@Service(version = "1.0.0")
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML}) // #2
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
@Path("/")
@RestController
public class CalculateServiceImpl implements CalculateService {

    @Override
    @GET
    @Path("/divide")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML}) // #2
    @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
//    @GetMapping(value="/divide")
    public int divide(@QueryParam(value = "a") int a, @QueryParam(value = "b") int b) {
        return 0;
    }

    @Override
    @GET
    @Path("/divide-test")
    @GetMapping(value="/divide-test")
    public int divideTest() {
        return 5;
    }

}
